package common.com.androidbase.datarequest;

public class ListResourcesDataType {
    /**
     * 一级分类
     *******************************************************************/
    private static final int TYPE_ALBUM = 0x01;// 专辑-0001
    private static final int TYPE_VIDEO = 0x02;// 视频-0010
    private static final int TYPE_ACCOUNT = 0x03;// 账号-0011
    private static final int TYPE_LABEL = 0x04;// 标签-0100
    private static final int TYPE_LIVE = 0x05;// 直播-0101
    private static final int TYPE_SCHEDULE = 0x06;// 赛程-0110

    /**
     * 二级分类
     *******************************************************************/
    private static final int SUB_TYPE_AMERICAN = 0x01;// 美剧 0001
    private static final int SUB_TYPE_PGC = 0x02;// PGC 0010
    private static final int SUB_TYPE_VIP = 0x03;// VIP 0011
    private static final int SUB_TYPE_STAR = 0x04;// 明星 0100
    private static final int SUB_TYPE_UGC = 0x05;// UGC 0101
    private static final int SUB_TYPE_NULL = 0; // 单集付费 0

    /**
     * 三级分类
     ******************************************************************/
    private static final int THIRD_TYPE_SINGLE_PAY = 0x01; // 付费剧集

    private static final int TYPE_FLAG = 0x0F;
    private static final int SUB_TYPE_FLAG = 0xF0;
    private static final int THIRD_TYPE_FLAG = 0xF00;

    /**
     * 获取一级分类
     *
     * @param dataType
     * @return
     */
    private static int getTypeFlag(int dataType) {
        int flag = (dataType & TYPE_FLAG);
        return flag;
    }

    /**
     * 获取二级分类
     *
     * @param dataType
     * @return
     */
    private static int getSubTypeFlag(int dataType) {
        int flag = (dataType & SUB_TYPE_FLAG) >> 4;
        return flag;
    }

    private static int getThirdTypeFlag(int dataType) {
        int flag = (dataType & THIRD_TYPE_FLAG) >> 8;
        return flag;
    }

    /**
     * 一级分类为专辑
     *
     * @param dataType e.g. 111100000001,33
     * @return
     */
    public static boolean isTypeAlbum(int dataType) {
        return (TYPE_ALBUM == getTypeFlag(dataType));
    }

    /**
     * 一级分类为视频
     *
     * @param dataType
     * @return
     */
    public static boolean isTypeVideo(int dataType) {
        return (TYPE_VIDEO == getTypeFlag(dataType));
    }

    /**
     * 一级分类为账户
     *
     * @param dataType
     * @return
     */
    public static boolean isTypeAccount(int dataType) {
        return (TYPE_ACCOUNT == getTypeFlag(dataType));
    }

    /**
     * 一级分类为标签
     *
     * @param dataType
     * @return
     */
    public static boolean isTypeLabel(int dataType) {
        return (TYPE_LABEL == getTypeFlag(dataType));
    }

    /**
     * 一级分类为直播
     *
     * @param dataType
     * @return
     */
    public static boolean isTypeLive(int dataType) {
        return (TYPE_LIVE == getTypeFlag(dataType));
    }

    /**
     * 一级分类为赛程
     *
     * @param dataType
     * @return
     */
    public static boolean isTypeSchedule(int dataType) {
        return (TYPE_SCHEDULE == getTypeFlag(dataType));
    }

    /**
     * 二级分类为美剧
     *
     * @param dataType
     * @return
     */
    public static boolean isSubTypeAmerican(int dataType) {
        return (SUB_TYPE_AMERICAN == getSubTypeFlag(dataType));
    }

    /**
     * 二级分类为PGC
     *
     * @param dataType
     * @return
     */
    public static boolean isSubTypePGC(int dataType) {
        return (SUB_TYPE_PGC == getSubTypeFlag(dataType));
    }

    /**
     * 二级分类为UGC
     * @param dataType
     * @return
     */
    public static boolean isSubTypeUGC(int dataType) {
        return (SUB_TYPE_UGC == getSubTypeFlag(dataType));
    }

    /**
     * 二级分类为VIP
     *
     * @param dataType
     * @return
     */
    public static boolean isSubTypeVIP(int dataType) {
        return (SUB_TYPE_VIP == getSubTypeFlag(dataType));
    }

    /**
     * 二级分类为明星
     *
     * @param dataType
     * @return
     */
    public static boolean isSubTypeStar(int dataType) {
        return (SUB_TYPE_STAR == getSubTypeFlag(dataType));
    }

    /**
     * 三级分类为单集付费
     */
    public static boolean isSinglePayType(int dataType) {
        return THIRD_TYPE_SINGLE_PAY == getThirdTypeFlag(dataType) & !isSubTypePGC(dataType);
    }

    /**
     * pgc付费剧集
     */
    public static boolean isSubTypePGCPay(int dataType) {
        return THIRD_TYPE_SINGLE_PAY == getThirdTypeFlag(dataType) & isSubTypePGC(dataType);
    }
}
